package com.flyaudio.xiaopengautopilot.util;

import android.content.Context;
import android.content.SharedPreferences;

public class MySharedPreferences {
    private static Context mContext;
    private static String SHARED_NAME = "preferences";
    private static SharedPreferences mPreference = null;

    public static void attachContext(Context context) {

        if (context != null && mContext == null) {
            mContext = context;
            mPreference = mContext.getSharedPreferences(SHARED_NAME,
                    Context.MODE_PRIVATE);
        }
    }

    public static boolean getPowerChargingLimitMode() {
        if (mPreference != null) {
            return mPreference.getBoolean("limit_mode", true);
        }
        return false;
    }

    public static boolean setPowerChargingLimitMode(boolean isFull) {
        if (mPreference != null) {
            if (mPreference != null) {
                SharedPreferences.Editor ed = mPreference.edit();
                ed.putBoolean("limit_mode", isFull);
                ed.commit();
            }
        }
        return false;
    }

    public static boolean getPowerComsumptionKmSwitch() {
        if (mPreference != null) {
            return mPreference.getBoolean("power_consumption_10_100", true);
        }
        return false;
    }

    public static boolean setPowerComsumptionKmSwitch(boolean is10km) {
        if (mPreference != null) {
            if (mPreference != null) {
                SharedPreferences.Editor ed = mPreference.edit();
                ed.putBoolean("power_consumption_10_100", is10km);
                ed.commit();
            }
        }
        return false;
    }




}
